package com.shop.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shop.mapper.DtsGoodsAttributeMapper;
import com.shop.pojo.DtsGoodsAttribute;
import com.shop.service.DtsGoodsAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClassName DtsGoodsAttributeServiceImpl
 * @Author xiao宋
 * @Date 21:00  2022/10/17
 * @Version 1.0
 * @Description TODO
 */
@Service
public class DtsGoodsAttributeServiceImpl implements DtsGoodsAttributeService {
    @Autowired
    DtsGoodsAttributeMapper attributeMapper;
    @Override
    public void insert(DtsGoodsAttribute attribute) {
        attribute.setAddTime(new Date());
        attribute.setUpdateTime(new Date());
        attribute.setDeleted(false);
        attributeMapper.insert(attribute);
    }

    @Override
    public void deleteByGoodsId(Integer goodsId) {
        LambdaQueryWrapper<DtsGoodsAttribute> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsAttribute::getGoodsId, goodsId);
        attributeMapper.delete(wrapper);
    }
}
